package client;

import java.io.Serializable;

import javax.swing.JOptionPane;

/**
 * 
 * Handles order delivery details
 *
 */
public class Delivery implements Serializable{
	
	/**
	 * Member id number
	 */
	int uid;
	/**
	 * recipient name
	 */
	String recName;
	/**
	 * recipient address
	 */
	String recAddress;
	/**
	 * recipient phone number
	 */
	String recPhone;
	

	String[] deliveryDateTime;
	
	/**
	 * Gets Member ID 
	 * @return member id number
	 */
	public int getUID()
	{
		return uid;
	}
	
	/**
	 * Sets recipient name
	 * @param name recipient name
	 */
	public void setRecName(String name)
	{
		this.recName=name;
	}
	
	/**
	 * Sets recipient address
	 * @param add recipient address
	 */
	public void setRecAddress(String add)
	{
		this.recAddress=add;
	}
	
	public void setDateTime(String[] del)
	{
		deliveryDateTime=new String[4];
		deliveryDateTime=del;
	}
	
	public String[] getDeliveryDateTime()
	{
		return deliveryDateTime;
	}
	
	/**
	 * Sets recipient phone number
	 * @param phone recipient phone number
	 */
	public void setRecPhone(String phone)
	{
		this.recPhone=phone;
	}
	
	/**
	 * Gets recipient name 
	 * @return recipient name
	 */
	public String getRecName()
	{
		return recName;
	}
	
	/**
	 * Gets recipient address
	 * @return recipient address
	 */
	public String getRecAddress()
	{
		return recAddress;
	}
	
	/**
	 * Gets recipient phone number
	 * @return recipient phone number
	 */
	public String getRecPhone()
	{
		return recPhone;
	}
	
	/**
	 * If self delivery is checked then gets the members details
	 * @param uid Member id number
	 * @param name Member name
	 */
	public void getRec(int uid,String name)
	{
		this.uid=uid;
		this.recName=name;
		
		ObjHandle.sendToServer(this);
		
		this.recAddress=((Delivery)Main.clie.getResult()).getRecAddress();
		this.recPhone=((Delivery)Main.clie.getResult()).getRecPhone();
	}
	
	public static void removeFromDB(Integer i) 
	{
		String[] sn=new String[2];
		sn[0]="Remove Delivery";
		sn[1]=i.toString();
		
		ObjHandle.sendToServer(sn);
	}
	
	public void setDelivery(String name,String address,String phone,String oid)
	{
		String[] sn=new String[5]; 
		sn[0]="set delivery";
		sn[1]=name;
		sn[2]=address;
		sn[3]=phone;
		sn[4]=oid;
		ObjHandle.sendToServer(sn);
	}
	
}
